package pucp.carpooling;

import java.lang.reflect.Field;
import pucp.carpooling.adapter.ViewPagerAdapterViajes;
import com.actionbarsherlock.app.SherlockFragment;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import pucp.carpooling.R;

public class FragmentViewPagerViajes extends SherlockFragment {

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View view = inflater.inflate(R.layout.viewpager_viajes, container, false);
	
		ViewPager mViewPager = (ViewPager) view.findViewById(R.id.viewPagerViajes);
		mViewPager.setAdapter(new ViewPagerAdapterViajes(getChildFragmentManager()));
		
//		try {
//			Bundle b = getArguments();
//			String jsonLogin =b.getString("jsonLogin");
//			JSONObject usuarioLogeado = new JSONObject (jsonLogin);
//			String PucpCode = usuarioLogeado.getString("PucpCode");
//			Log.d("Imprimiendo Json en Pager", jsonLogin);
//		}
//		catch (Exception e) {
//			
//		}
		return view;
	}

	@Override
	public void onDetach() {
		super.onDetach();
		try {
			Field childFragmentManager = Fragment.class
					.getDeclaredField("mChildFragmentManager");
			childFragmentManager.setAccessible(true);
			childFragmentManager.set(this, null);
		} catch (NoSuchFieldException e) {
			throw new RuntimeException(e);
		} catch (IllegalAccessException e) {
			throw new RuntimeException(e);
		}
	}
}
